package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * Created by 罗海量
 * 2018-07-22 19:53
 */
@Entity
@Table(name = "sys_transaction")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class Transaction {

    private String id;
    private Long eggId;
    private String sellId;
    private String buyId;
    private BigDecimal sellIncome;
    private String prCode;
    private String prUserId;
    private BigDecimal prIncome;
    private BigDecimal serviceFee;
    private BigDecimal buyExpense;
    private Timestamp createTime;
    private Long txReqId;
    private Integer txStatus;
    private Integer errCode;
    private String errDesc;
    private Long version;

    @Id
    @Column(name = "ID")
    @GenericGenerator(name = "tx-uuid", strategy = "uuid")
    @GeneratedValue(generator = "tx-uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "EGG_ID")
    public Long getEggId() {
        return eggId;
    }

    public void setEggId(Long eggId) {
        this.eggId = eggId;
    }

    @Basic
    @Column(name = "SELL_ID")
    public String getSellId() {
        return sellId;
    }

    public void setSellId(String sellId) {
        this.sellId = sellId;
    }

    @Basic
    @Column(name = "BUY_ID")
    public String getBuyId() {
        return buyId;
    }

    public void setBuyId(String buyId) {
        this.buyId = buyId;
    }

    @Basic
    @Column(name = "SELL_INCOME")
    public BigDecimal getSellIncome() {
        return sellIncome;
    }

    public void setSellIncome(BigDecimal sellIncome) {
        this.sellIncome = sellIncome;
    }

    @Basic
    @Column(name = "PR_CODE")
    public String getPrCode() {
        return prCode;
    }

    public void setPrCode(String prCode) {
        this.prCode = prCode;
    }

    @Basic
    @Column(name = "PR_USER_ID")
    public String getPrUserId() {
        return prUserId;
    }

    public void setPrUserId(String prUserId) {
        this.prUserId = prUserId;
    }

    @Basic
    @Column(name = "PR_INCOME")
    public BigDecimal getPrIncome() {
        return prIncome;
    }

    public void setPrIncome(BigDecimal prIncome) {
        this.prIncome = prIncome;
    }

    @Basic
    @Column(name = "SERVICE_FEE")
    public BigDecimal getServiceFee() {
        return serviceFee;
    }

    public void setServiceFee(BigDecimal serviceFee) {
        this.serviceFee = serviceFee;
    }

    @Basic
    @Column(name = "BUY_EXPENSE")
    public BigDecimal getBuyExpense() {
        return buyExpense;
    }

    public void setBuyExpense(BigDecimal buyExpense) {
        this.buyExpense = buyExpense;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "TX_REQ_ID")
    public Long getTxReqId() {
        return txReqId;
    }

    public void setTxReqId(Long txReqId) {
        this.txReqId = txReqId;
    }

    @Basic
    @Column(name = "TX_STATUS")
    public Integer getTxStatus() {
        return txStatus;
    }

    public void setTxStatus(Integer txStatus) {
        this.txStatus = txStatus;
    }

    @Basic
    @Column(name = "ERR_CODE")
    public Integer getErrCode() {
        return errCode;
    }

    public void setErrCode(Integer errCode) {
        this.errCode = errCode;
    }

    @Basic
    @Column(name = "ERR_DESC")
    public String getErrDesc() {
        return errDesc;
    }

    public void setErrDesc(String errDesc) {
        this.errDesc = errDesc;
    }

    @Column(name = "VERSION")
    @Version
    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Transaction that = (Transaction) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (eggId != null ? !eggId.equals(that.eggId) : that.eggId != null) return false;
        if (sellId != null ? !sellId.equals(that.sellId) : that.sellId != null) return false;
        if (buyId != null ? !buyId.equals(that.buyId) : that.buyId != null) return false;
        if (sellIncome != null ? !sellIncome.equals(that.sellIncome) : that.sellIncome != null) return false;
        if (prCode != null ? !prCode.equals(that.prCode) : that.prCode != null) return false;
        if (prUserId != null ? !prUserId.equals(that.prUserId) : that.prUserId != null) return false;
        if (prIncome != null ? !prIncome.equals(that.prIncome) : that.prIncome != null) return false;
        if (serviceFee != null ? !serviceFee.equals(that.serviceFee) : that.serviceFee != null) return false;
        if (buyExpense != null ? !buyExpense.equals(that.buyExpense) : that.buyExpense != null) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (txReqId != null ? !txReqId.equals(that.txReqId) : that.txReqId != null) return false;
        if (txStatus != null ? !txStatus.equals(that.txStatus) : that.txStatus != null) return false;
        if (errCode != null ? !errCode.equals(that.errCode) : that.errCode != null) return false;
        if (errDesc != null ? !errDesc.equals(that.errDesc) : that.errDesc != null) return false;
        if (version != null ? !version.equals(that.version) : that.version != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}
